package com.xyd.Biz.Impl;

import com.xyd.Biz.ProductCarBiz;
import com.xyd.Dao.ProductCarDao;
import com.xyd.Entity.ProductCar;
import com.xyd.Util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @ClassName: ProductCarBizImpl
 * @Description:
 * @Author 余全盛
 * @Date: 2021/10/15 20:10
 */
public class ProductCarBizImpl implements ProductCarBiz {
    ProductCarDao productCarDao = null;

    public ProductCarBizImpl() {
        SqlSession session = SqlSessionFactoryUtil.open();
        productCarDao = session.getMapper(ProductCarDao.class);
    }

    @Override
    public int addProductToCar(int pruductid, String productname, double price, int userid) {
        return productCarDao.addProductToCar(pruductid, productname, price, userid);
    }

    @Override
    public List<ProductCar> selectAllProductCarByID(int userid) {
        return productCarDao.selectAllProductCarByID(userid);
    }

    @Override
    public ProductCar selectProductCarByUserIDAndProductId(int porductid, int userid) {
        return productCarDao.selectProductCarByUserIDAndProductId(porductid, userid);
    }

    @Override
    public int updateProductCarNum(int porductid, int userid) {
        return productCarDao.updateProductCarNum(porductid, userid);
    }

    @Override
    public int updateProductCar(int productid, int num, int userid) {
        return productCarDao.updateProductCar(productid, num, userid);
    }

    @Override
    public int deleteProductCarByID(int productid, int userid) {
        return productCarDao.deleteProductCarByID(productid, userid);
    }

    @Override
    public int deleteAllProductCar(int userid) {
        return productCarDao.deleteAllProductCar(userid);
    }

    @Override
    public int deleteAllPayedProductCar(int userid) {
        return productCarDao.deleteAllPayedProductCar(userid);
    }
}
